//4.观察者模式之callbacks
window.JQuery ={
    callbacks(){
        let callbacks = [];
        function  add(callback) { 
            callbacks.push(callback) 
        };
        function  remote(callback) { 
            callbacks = callbacks.filter(item=>item != callback); 
        };
        function  fire(callback) { 
            callbacks.forEach(item=>item())
        };
        return {
            add,
            remote,
            fire
        }
    }
}
